package com.pei.Dao.Impl;


import com.pei.Dao.user_typeDao;
import com.pei.entity.user_type;
import com.pei.util.BaseDao;


import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by dell on 2018/8/6.
 */
public class user_typeDaoImpl implements user_typeDao
{

    @Override
    public List<user_type> finduser_type(int utid) {
        List<user_type> slist=new ArrayList<user_type>();
        Connection conn=null;
        PreparedStatement stat=null;
        ResultSet rs=null;
        String sql="select utname from user_type where utid=?";
        try {
            conn= BaseDao.getConnection();
            stat=conn.prepareStatement(sql);
            stat.setInt(1,utid);
            rs=stat.executeQuery();
            while (rs.next()){
                user_type ut=new user_type();
                ut.setUtname(rs.getString("utname"));
                slist.add(ut);
            }
        }catch (Exception e){
            System.out.print(e.getMessage());
        }finally {
            BaseDao.closeConnection(conn,stat,rs);
        }
        return slist;
    }
}
